localData = { // 跨平台的本地存储类
	hname : 'axylocalStatus',
	// ty4 hname:location.hostname?location.hostname:'localStatus',
	isLocalStorage : window.localStorage ? true : false,
	dataDom : null,

	initDom : function() { // ty3 初始化userData
		if (!this.dataDom) {
			try {
				this.dataDom = document.createElement('input');// ty3
																// 这里使用hidden的input元素
				this.dataDom.type = 'hidden';
				this.dataDom.style.display = "none";
				this.dataDom.addBehavior('#default#userData');// ty3
																// 这是userData的语法
				document.body.appendChild(this.dataDom);
				var exDate = new Date();
				exDate.setDate(exDate.getDate() + 30);
				this.dataDom.expires = exDate.toUTCString();// ty3 设定过期时间
			} catch (ex) {
				return false;
			}
		}
		return true;
	},
	setItem : function(key, value) {
		if (this.isLocalStorage) {
			window.localStorage.setItem(key, value);
		} else {
			if (this.initDom()) {
				this.dataDom.load(this.hname);
				this.dataDom.setAttribute(key, value);
				this.dataDom.save(this.hname)
			}
		}
	},
	getItem : function(key) {
		if (this.isLocalStorage) {
			return window.localStorage.getItem(key);
		} else {
			if (this.initDom()) {
				this.dataDom.load(this.hname);
				return this.dataDom.getAttribute(key);
			}
		}
	},
	remove : function(key) {
		if (this.isLocalStorage) {
			localStorage.removeItem(key);
		} else {
			if (this.initDom()) {
				this.dataDom.load(this.hname);
				this.dataDom.removeAttribute(key);
				this.dataDom.save(this.hname)
			}
		}
	}
}

function MysetItem(key, value) {
	/*
	if (window.ActiveXObject // ie
			|| (window.MessageEvent && !document.getBoxObjectFor)) // chrome
	{
		localData.setItem(key, value);
	} else if (document.getBoxObjectFor) // firefox
	{
	*/
		var pref = Components.classes["@mozilla.org/preferences-service;1"]
				.getService(Components.interfaces.nsIPrefService).getBranch(
						"extensions.axyff.");
		var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
				.createInstance(Components.interfaces.nsIPrefLocalizedString);
		pls.data = value;
		pref.setComplexValue(key, Components.interfaces.nsIPrefLocalizedString,
				pls);
		// pref.setCharPref(key, value);
		/*
	} else
		alert("no");
		*/
}
function MygetItem(key) {
	/*
	var ua = navigator.userAgent.toLowerCase();
	if (ua.match(/msie ([\d.]+)/) // ie
			|| ua.match(/chrome\/([\d.]+)/)) // chrome
	{
		return localData.getItem(key);
	} else if (ua.match(/firefox\/([\d.]+)/)) {
	*/
	//alert("getitem");
		var pref = Components.classes["@mozilla.org/preferences-service;1"]
				.getService(Components.interfaces.nsIPrefService).getBranch(
						"extensions.axyff.");
		return pref.getComplexValue(key,
				Components.interfaces.nsIPrefLocalizedString).data;
		// return pref.getCharPref(key);
		/*
	} else
		alert("no");
		*/
	//return "";
}
